Resolves; tdf#87120 no keyboard navigation inside floating windows
lets try and treat these the same as we do normal toplevels
like dialogs if they popup with GrabFocus.
This way focus can be set on widgets inside the floating windows, and
so keyboard traversal of widgets etc all works.
Change-Id: If447429756cf5d136b9c2e2f62fafb37c167b1ce
diff --git a/include/vcl/edit.hxx b/include/vcl/edit.hxx
index 57a8e07..ce686d4 100644
--- a/include/vcl/edit.hxx
+++ b/include/vcl/edit.hxx
@@ -186,7 +186,6 @@
virtual void Command( const CommandEvent& rCEvt ) override;
virtual void StateChanged( StateChangedType nType ) override;
virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
virtual vcl::Window* GetPreferredKeyInputWindow() override;
virtual void Modify();
virtual void UpdateData();
diff --git a/include/vcl/lstbox.hxx b/include/vcl/lstbox.hxx
index 09067d2..3276e3e 100644
--- a/include/vcl/lstbox.hxx
+++ b/include/vcl/lstbox.hxx
@@ -134,7 +134,6 @@
virtual void DoubleClick();
virtual void GetFocus() override;
virtual void LoseFocus() override;
virtual vcl::Window* GetPreferredKeyInputWindow() override;
virtual const Wallpaper& GetDisplayBackground() const override;
diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx
index 5b0fd16..1f0cddd 100644
--- a/include/vcl/window.hxx
+++ b/include/vcl/window.hxx
@@ -824,7 +824,6 @@
virtual void DataChanged( const DataChangedEvent& rDCEvt );
virtual bool PreNotify( NotifyEvent& rNEvt );
virtual bool Notify( NotifyEvent& rNEvt );
virtual vcl::Window* GetPreferredKeyInputWindow();
// These methods call the relevant virtual method when not in/post dispose
void CompatGetFocus();
diff --git a/sc/source/ui/cctrl/checklistmenu.cxx b/sc/source/ui/cctrl/checklistmenu.cxx
index be5f356..fa943fc 100644
--- a/sc/source/ui/cctrl/checklistmenu.cxx
+++ b/sc/source/ui/cctrl/checklistmenu.cxx
@@ -1327,11 +1327,6 @@
rRenderContext.DrawRect(Rectangle(aPos,aSize));
}
vcl::Window* ScCheckListMenuWindow::GetPreferredKeyInputWindow()
{
return maTabStops.GetCurrentControl();
}
Reference<XAccessible> ScCheckListMenuWindow::CreateAccessible()
{
if (!mxAccessible.is())
diff --git a/sc/source/ui/inc/checklistmenu.hxx b/sc/source/ui/inc/checklistmenu.hxx
index fa104ed..8824acb 100644
--- a/sc/source/ui/inc/checklistmenu.hxx
+++ b/sc/source/ui/inc/checklistmenu.hxx
@@ -299,7 +299,6 @@
virtual void MouseMove(const MouseEvent& rMEvt) override;
virtual bool Notify(NotifyEvent& rNEvt) override;
virtual void Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect) override;
virtual vcl::Window* GetPreferredKeyInputWindow() override;
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override;
void setMemberSize(size_t n);
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 33de00a..1a8ed51 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -347,8 +347,6 @@
ScFilterFloatingWindow( vcl::Window* pParent, WinBits nStyle = WB_STDFLOATWIN );
virtual ~ScFilterFloatingWindow();
virtual void dispose() override;
// required for System FloatingWindows that will not process KeyInput by themselves
virtual vcl::Window* GetPreferredKeyInputWindow() override;
};
ScFilterFloatingWindow::ScFilterFloatingWindow( vcl::Window* pParent, WinBits nStyle ) :
@@ -366,12 +364,6 @@
FloatingWindow::dispose();
}
vcl::Window* ScFilterFloatingWindow::GetPreferredKeyInputWindow()
{
// redirect keyinput in the child window
return GetWindow(GetWindowType::FirstChild) ? GetWindow(GetWindowType::FirstChild)->GetPreferredKeyInputWindow() : nullptr; // will be the FilterBox
}
static bool lcl_IsEditableMatrix( ScDocument* pDoc, const ScRange& rRange )
{
// If it is a editable range and if there is a Matrix cell at the bottom right with an
diff --git a/svx/source/tbxctrls/lboxctrl.cxx b/svx/source/tbxctrls/lboxctrl.cxx
index e5e83d6..e5141f1 100644
--- a/svx/source/tbxctrls/lboxctrl.cxx
+++ b/svx/source/tbxctrls/lboxctrl.cxx
@@ -73,7 +73,6 @@
bool IsUserSelected() const { return bUserSel; }
void SetUserSelected( bool bVal ) { bUserSel = bVal; }
virtual vcl::Window* GetPreferredKeyInputWindow() override;
};
SvxPopupWindowListBox::SvxPopupWindowListBox(sal_uInt16 nSlotId, const OUString& rCommandURL, sal_uInt16 nId, ToolBox& rTbx)
@@ -128,13 +127,6 @@
SfxPopupWindow::StateChanged( nSID, eState, pState );
}
vcl::Window* SvxPopupWindowListBox::GetPreferredKeyInputWindow()
{
// allows forwarding key events in the correct window
// without setting the focus
return m_pListBox->GetPreferredKeyInputWindow();
}
SvxListBoxControl::SvxListBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx )
:SfxToolBoxControl( nSlotId, nId, rTbx ),
pPopupWin ( nullptr )
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index 6637626..dc70581 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -259,7 +259,6 @@
protected:
virtual void Resize() override;
virtual bool Close() override;
virtual vcl::Window* GetPreferredKeyInputWindow() override;
virtual void GetFocus() override;
public:
@@ -285,9 +284,7 @@
protected:
virtual void Resize() override;
virtual bool Close() override;
virtual vcl::Window* GetPreferredKeyInputWindow() override;
virtual void GetFocus() override;
virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
public:
SvxLineWindow_Impl( sal_uInt16 nId, const Reference< XFrame >& rFrame, vcl::Window* pParentWindow );
virtual ~SvxLineWindow_Impl() { disposeOnce(); }
@@ -1659,11 +1656,6 @@
SfxPopupWindow::dispose();
}
vcl::Window* SvxFrameWindow_Impl::GetPreferredKeyInputWindow()
{
return aFrameSet.get();
}
void SvxFrameWindow_Impl::GetFocus()
{
if (aFrameSet)
@@ -2043,28 +2035,11 @@
return SfxPopupWindow::Close();
}
vcl::Window* SvxLineWindow_Impl::GetPreferredKeyInputWindow()
{
return m_aLineStyleLb.get();
}
void SvxLineWindow_Impl::GetFocus()
{
m_aLineStyleLb->GrabFocus();
}
void SvxLineWindow_Impl::DataChanged( const DataChangedEvent& rDCEvt )
{
SfxPopupWindow::DataChanged( rDCEvt );
#if 0
if( ( rDCEvt.GetType() == DataChangedEventType::SETTINGS ) && ( rDCEvt.GetFlags() & AllSettingsFlags::STYLE ) )
{
CreateBitmaps();
Invalidate();
}
#endif
}
SfxStyleControllerItem_Impl::SfxStyleControllerItem_Impl(
const Reference< XDispatchProvider >& rDispatchProvider,
sal_uInt16 nSlotId, // Family-ID
diff --git a/vcl/inc/listbox.hxx b/vcl/inc/listbox.hxx
index 863bef6..3cd6944 100644
--- a/vcl/inc/listbox.hxx
+++ b/vcl/inc/listbox.hxx
@@ -406,7 +406,6 @@
virtual void Resize() override;
virtual const Wallpaper& GetDisplayBackground() const override;
virtual vcl::Window* GetPreferredKeyInputWindow() override;
sal_Int32 InsertEntry( sal_Int32 nPos, const OUString& rStr );
sal_Int32 InsertEntry( sal_Int32 nPos, const OUString& rStr, const Image& rImage );
diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx
index 9dab058..231422d 100644
--- a/vcl/source/control/edit.cxx
+++ b/vcl/source/control/edit.cxx
@@ -1945,14 +1945,6 @@
Control::GetFocus();
}
vcl::Window* Edit::GetPreferredKeyInputWindow()
{
if ( mpSubEdit )
return mpSubEdit->GetPreferredKeyInputWindow();
else
return this;
}
void Edit::LoseFocus()
{
if ( mpUpdateDataTimer && !mbIsSubEdit && mpUpdateDataTimer->IsActive() )
diff --git a/vcl/source/control/imp_listbox.cxx b/vcl/source/control/imp_listbox.cxx
index 61b9373..2d3424f 100644
--- a/vcl/source/control/imp_listbox.cxx
+++ b/vcl/source/control/imp_listbox.cxx
@@ -2224,11 +2224,6 @@
Control::GetFocus();
}
vcl::Window* ImplListBox::GetPreferredKeyInputWindow()
{
return maLBWindow.get();
}
void ImplListBox::Resize()
{
Control::Resize();
diff --git a/vcl/source/control/listbox.cxx b/vcl/source/control/listbox.cxx
index 3602232..1cbcc4d 100644
--- a/vcl/source/control/listbox.cxx
+++ b/vcl/source/control/listbox.cxx
@@ -496,19 +496,6 @@
Control::GetFocus();
}
vcl::Window* ListBox::GetPreferredKeyInputWindow()
{
if ( mpImplLB )
{
if( IsDropDownBox() )
return mpImplWin->GetPreferredKeyInputWindow();
else
return mpImplLB->GetPreferredKeyInputWindow();
}
return Control::GetPreferredKeyInputWindow();
}
void ListBox::LoseFocus()
{
if( IsDropDownBox() )
diff --git a/vcl/source/window/dockmgr.cxx b/vcl/source/window/dockmgr.cxx
index 653b663..7e9172f 100644
--- a/vcl/source/window/dockmgr.cxx
+++ b/vcl/source/window/dockmgr.cxx
@@ -488,7 +488,6 @@
virtual void MouseButtonUp( const MouseEvent& rMEvt ) override;
virtual void Tracking( const TrackingEvent& rTEvt ) override;
virtual void Resize() override;
virtual vcl::Window* GetPreferredKeyInputWindow() override;
Rectangle GetDragRect() const;
Point GetToolboxPosition() const;
@@ -536,14 +535,6 @@
return css::uno::Reference< css::accessibility::XAccessible >();
}
vcl::Window* ImplPopupFloatWin::GetPreferredKeyInputWindow()
{
if( mpWindowImpl->mpClientWindow )
return mpWindowImpl->mpClientWindow;
else
return FloatingWindow::GetPreferredKeyInputWindow();
}
void ImplPopupFloatWin::ImplSetBorder()
{
// although we have no border in the sense of a borderwindow
@@ -1152,7 +1143,7 @@
{
// send HOME key to subtoolbar in order to select first item
KeyEvent aEvent( 0, vcl::KeyCode( KEY_HOME ) );
mpFloatWin->GetPreferredKeyInputWindow()->KeyInput( aEvent );
mpFloatWin->KeyInput(aEvent);
}
}
diff --git a/vcl/source/window/floatwin.cxx b/vcl/source/window/floatwin.cxx
index 6553f94..9492e9c 100644
--- a/vcl/source/window/floatwin.cxx
+++ b/vcl/source/window/floatwin.cxx
@@ -715,6 +715,8 @@
{
// force key input even without focus (useful for menus)
mbGrabFocus = true;
mpWindowImpl->mpFrameData->mbHasFocus = true;
GrabFocus();
}
Show( true, ShowFlags::NoActivate );
}
diff --git a/vcl/source/window/mouse.cxx b/vcl/source/window/mouse.cxx
index 892d419..4782c15 100644
--- a/vcl/source/window/mouse.cxx
+++ b/vcl/source/window/mouse.cxx
@@ -273,9 +273,7 @@
vcl::Window *pParent = this;
while( pParent )
{
// #102158#, ignore grabfocus only if the floating parent grabs keyboard focus by itself (GrabsFocus())
// otherwise we cannot set the focus in a floating toolbox
if( ( (pParent->mpWindowImpl->mbFloatWin && static_cast<FloatingWindow*>(pParent)->GrabsFocus()) || ( pParent->GetStyle() & WB_SYSTEMFLOATWIN ) ) && !( pParent->GetStyle() & WB_MOVEABLE ) )
if ((pParent->GetStyle() & WB_SYSTEMFLOATWIN) && !(pParent->GetStyle() & WB_MOVEABLE))
{
bMustNotGrabFocus = true;
break;
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 1092c4e..5d630fa 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -3443,13 +3443,6 @@
SetLineColor( oldLineCol );
}
// controls should return the window that gets the
// focus by default, so keyevents can be sent to that window directly
vcl::Window* Window::GetPreferredKeyInputWindow()
{
return this;
}
bool Window::IsScrollable() const
{
// check for scrollbars
diff --git a/vcl/source/window/winproc.cxx b/vcl/source/window/winproc.cxx
index b2de412..062136e 100644
--- a/vcl/source/window/winproc.cxx
+++ b/vcl/source/window/winproc.cxx
@@ -821,10 +821,7 @@
if( !pChild || ( pChild->ImplGetWindowImpl()->mbFloatWin && !static_cast<FloatingWindow *>(pChild)->GrabsFocus() ) )
pChild = pWindow->ImplGetWindowImpl()->mpFrameData->mpFocusWin;
else
{
// allow floaters to forward keyinput to some member
pChild = pChild->GetPreferredKeyInputWindow();
}
pChild = pChild->ImplGetWindowImpl()->mpFrameData->mpFocusWin;
// no child - than no input
if ( !pChild )